.\" generated with Ronn/v0.7.3
.\" http://github.com/rtomayko/ronn/tree/0.7.3
.
.TH "GIT\-IGNORE" "1" "April 2018" "" "Git Extras"
.
.SH "NAME"
\fBgit\-ignore\fR \- Add \.gitignore patterns
.
.SH "SYNOPSIS"
\fBgit\-ignore\fR [<context>] [<pattern> [<pattern>]\.\.\.]
.
.SH "DESCRIPTION"
Adds the given _pattern_s to a \.gitignore file if it doesn\'t already exist\.
.
.SH "OPTIONS"
<context>
.
.P
\-l, \-\-local
.
.P
Sets the context to the \.gitignore file in the current working directory\. (default)
.
.P
\-g, \-\-global
.
.P
Sets the context to the global gitignore file for the current user\.
.
.P
\-p, \-\-private
.
.P
Sets the context to the private exclude file for the repository (\fB\.git/info/exclude\fR)\.
.
.P
<pattern>
.
.P
A space delimited list of patterns to append to the file in context\.
.
.SS "PATTERN FORMAT"
Pattern format as described in the git manual
.
.IP "\(bu" 4
A blank line matches no files, so it can serve as a separator for readability\. To append a blank line use empty quotes ""\.
.
.IP "\(bu" 4
A line starting with # serves as a comment\. For example, "# This is a comment"
.
.IP "\(bu" 4
An optional prefix ! which negates the pattern; any matching file excluded by a previous pattern will become included again\. If a negated pattern matches, this will override lower precedence patterns sources\. To use an exclamation ! as command line argument it is best placed between single quotes \'\'\. For example, \'!src\'
.
.IP "\(bu" 4
If the pattern ends with a slash, it is removed for the purpose of the following description, but it would only find a match with a directory\. In other words, foo/ will match a directory foo and paths underneath it, but will not match a regular file or a symbolic link foo (this is consistent with the way how pathspec works in general in git)\.
.
.IP "\(bu" 4
If the pattern does not contain a slash /, git treats it as a shell glob pattern and checks for a match against the pathname relative to the location of the \.gitignore file (relative to the top level of the work tree if not from a \.gitignore file)\.
.
.IP "\(bu" 4
Otherwise, git treats the pattern as a shell glob suitable for consumption by fnmatch(3) with the FNM_PATHNAME flag: wildcards in the pattern will not match a / in the pathname\. For example, "Documentation/*\.html" matches "Documentation/git\.html" but not "Documentation/ppc/ppc\.html" or "tools/perf/Documentation/perf\.html"\.
.
.IP "\(bu" 4
A leading slash matches the beginning of the pathname\. For example, "/*\.c" matches "cat\-file\.c" but not "mozilla\-sha1/sha1\.c"\.
.
.IP "" 0
.
.SH "EXAMPLES"
All arguments are optional so calling git\-ignore alone will display first the global then the local gitignore files:
.
.IP "" 4
.
.nf

$ git ignore
Global gitignore: /home/alice/\.gitignore
# Numerous always\-ignore extensions
*\.diff
*\.err
*\.orig
*\.rej
*\.swo
*\.swp
*\.vi
*~
*\.sass\-cache

# OS or Editor folders
\.DS_Store
\.Trashes
\._*
Thumbs\.db
\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-
Local gitignore: \.gitignore
\.cache
\.project
\.settings
\.tmproj
nbproject
.
.fi
.
.IP "" 0
.
.P
If you only want to see the global context use the \-\-global argument (for local use \-\-local):
.
.IP "" 4
.
.nf

$ git ignore
Global gitignore: /home/alice/\.gitignore
\.DS_Store
\.Trashes
\._*
Thumbs\.db
.
.fi
.
.IP "" 0
.
.P
To quickly append a new pattern to the default/local context simply:
.
.IP "" 4
.
.nf

$ git ignore *\.log
Adding pattern(s) to: \.gitignore
\.\.\. adding \'*\.log\'
.
.fi
.
.IP "" 0
.
.P
You can now configure any patterns without ever using an editor, with a context and pattern arguments: The resulting configuration is also returned for your convenience\.
.
.IP "" 4
.
.nf

$ git ignore \-\-local "" "# Temporary files" *\.tmp "*\.log" tmp/*  "" "# Files I\'d like to keep" \'!work\'  ""
Adding pattern(s) to: \.gitignore
\.\.\. adding \'\'
\.\.\. adding \'# Temporary files\'
\.\.\. adding \'index\.tmp\'
\.\.\. adding \'*\.log\'
\.\.\. adding \'tmp/*\'
\.\.\. adding \'\'
\.\.\. adding \'# Files I\'d like to keep\'
\.\.\. adding \'!work\'
\.\.\. adding \'\'

Local gitignore: \.gitignore

# Temporary files
index\.tmp
*\.log

# Files I\'d like to keep
!work
.
.fi
.
.IP "" 0
.
.SH "AUTHOR"
Written by Tj Holowaychuk <\fItj@vision\-media\.ca\fR> and Tema Bolshakov <\fItweekane@gmail\.com\fR> and Nick Lombard <\fIgithub@jigsoft\.co\.za\fR>
.
.SH "REPORTING BUGS"
<\fIhttps://github\.com/tj/git\-extras/issues\fR>
.
.SH "SEE ALSO"
<\fIhttps://github\.com/tj/git\-extras\fR>
